<!DOCTYPE html>
<html lang="zh-CN" ng-app='he'>
	<head>
		<meta charset='utf-8' />
	
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>请假详情</title>
		<script type="text/javascript">
			is_local='{{local}}';
			function loadcss(cssfile) {
		        document.write('\<link rel="stylesheet" href="' + cssfile +'" type="text/css"/\>');
		    }
			function loadjs(script_filename) {
		        document.write('\<script language="javascript" type="text/javascript" src="' + script_filename + '"\>\</script\>');
		    }
		    if(!is_local){
			    static_url='/static';
		    }else{
			    static_url='../../../../static';
		    }
		    // 加载所有微信页面需要的js和css
		    loadjs(static_url+'/js/weixin_page.js')
		</script>
		
		<script type="text/javascript">
			var app = angular.module('he',['ngSanitize']);
			app.config(function($interpolateProvider) {
				  $interpolateProvider.startSymbol('[[');
				  $interpolateProvider.endSymbol(']]');
				});
			app.run(function($rootScope){
				$rootScope.static=static_url;
			})
			app.controller('content',function ($scope,$http,$location) {
				
				var leave_id = $location.search().id;
				// 测试下 #后面的变量
				//alert(leave_id);
				// 设置body里面的变量
				if(is_local){
					$scope.leave={
						category:'annual_leave',
						reason:'回家',
						start_time:'2016-01-28 08:30',
						end_time:'2016-02-01 17:30',
						create_time:'2016-01-25 14:32',
						status:'checking',
						check_record:[
							{name:'echo',status:'approved',note:'累死人'},
							{name:'liuhailong',status:'rejected',note:'不行'}
						]
					}
				}else{
					// 从服务器初始化
					var post_url='/attendance/ajax/';
					function init_from_server() {
							var post_data = {
									leave_detail:{leave_id:leave_id},
								};  
							$http.post(post_url,post_data)
							.success(function(data, status, headers, config) { 
								if (data.leave_detail.status=='success'){
									$scope.leave=data.leave_detail.leave
								}else{
									info(data.leave_detail.msg,function () {
										location='leave_record.html'
									})
								}
								
							}).error(function(data, status, headers, config) {  
							    //处理错误 
							    $scope.std='有错误,返回码为:'+status;
							});
					}
					init_from_server();
					//--------------------------------------
				}
			$scope.cannel_leave=function () {
				assure("when revoke leave,you can't Resume it again",function (b) {
				if(b){
					var postData = {
					revoke_leave:{leaveid:leave_id},
						};  
					$http.post(post_url,postData)
					.success(function(data, status, headers, config) {  
						if(data.revoke_leave.status=='success'){
							info('successful submit',function () {
								location="leave_record.html";
							});
						}else{
							info(data.revoke_leave.msg);
						}
					}).error(function(data, status, headers, config) {  
					    //处理错误 
					    info('有错误,返回码为:'+status)
					});
				}
				
			})
		};
				
			})
		</script>

<style>
		body{
			text-transform: capitalize;
		}
		.topDiv{
			padding: 1.5em 0;
			font-size: 1.5em;
			font-weight: 600;
			text-align: center;
			color: #ffffff;
			background: url("[[static]]/img/192396266.jpg") no-repeat center;
		}
		.timePut{
			height: 3em;
			line-height: 3em;
			border: 1px solid #1686E2;
			border-radius: 4px;
			vertical-align: middle;
			margin: 0.8em auto 0.8em 1.5em;
		}
		.invalid{
			border-color:#ff6014;
		}
		.valid{
			border-color:#1686E2;
		}
</style>
</head>
<body ng-controller='content'>
		<!-----------------弹出框------------------------>
	<div ng-include src='"info_panel.html"'></div>
		<!-----------------在这里填写内容------------------------>

	<div class="container">
		<div class="row">
			<div class="col-xs-12 clear">
				<p class="topDiv" ng-bind='leave.category'>Personal Leave</p>
			</div>
			<div class="col-xs-12 group">
				<label class="lag col-xs-5">Start Time : </label>
				<span class="col-xs-7" ng-bind='leave.start_time'>2016-01-28 08:30</span>
			</div>
			<div class="col-xs-12 group">
				<label class="lag col-xs-5">End Time : </label>
				<span class="col-xs-7" ng-bind='leave.end_time'>2016-02-01 17:30</span>
			</div>
			<div class="col-xs-12 group">
				<label class="lag col-xs-5">Reason : </label>
				<span class="col-xs-7" ng-bind='leave.reason'>回家探亲,请领导批准</span>
			</div>
			<div class="col-xs-12 group">
				<label class="lag col-xs-5">Application Date : </label>
				<span class="col-xs-7" ng-bind='leave.create_time'>2016-01-25 14:32</span>
			</div>
			<div class="col-xs-12 group">
				<label class="lag col-xs-5">AppState ：</label>
				<span class="col-xs-7" >
					<span ng-repeat='leader in leave.check_record'>
						 <span ng-bind='leader.name'></span>- <span ng-bind='leader.status'></span> <span class="timeStyle">2016-01-12 10:20</span>
						 <!-- -->
						<p ng-bind='leader.note'>dgsd</p>
					</span>

				</span>
			</div>

			<div class="col-xs-12 group">
				<label class="lag col-xs-5">Application status: </label>
				<span class="col-xs-7" ng-bind='leave.status'></span>
			</div>

				<!--<form action="" id="backTime">
					<div class="col-xs-12 group" style="text-align: center" >
						<label class="lag  ">Back ahead of time</label>
						<input type="datetime-local" class="timePut" ng-model='endtime' ng-class='dtinput_is_valid(endtime)?"valid":"invalid"'/>
					</div>
					<div class="btncenter" >
						<button type="button" class="btn btn-default submitBtn" ng-click='resumption()'>SUBMIT</button>
						<button name="test" type="button" class="btn btn-default submitBtn" value="val" onclick='back_click()'>back</button>
					</div>
				</form>-->
	
			<div class="btncenter"  id='menu'>
				<!--<button type="button" class="btn btn-primary" onclick='res()' ng-disabled='leave.status=="revoked"||leave.status=="rejected"'>Resumption</button>-->
				<button type="button" class="btn btn-warning" ng-click='cannel_leave()' ng-hide='leave.status!="pending"'>REVOCATION</button>
			</div>
		</div>
	</div>
<!--<script type="text/javascript">
    $(function(){
        $('#backTime').hide();
    });
    function res(){
        //$('.btnBox').slideUp("fast");
        $('#backTime').slideDown("fast");
        $('#menu').hide();
        
    };
    function back_click() {
	    $('#backTime').slideUp("fast");
    	$('#menu').slideDown('fast');
    }
  
</script>-->
		
	</body>
</html>